export class itemData 
{
    name:string = "名字";
    value1:number = 1;
    value2:number = 2;
    value3:number = 3;
}

export class testPanelmodel{

    private static _instance:testPanelmodel = null;
    static instance()
    {
        if(!this._instance)
        {
            this._instance = new testPanelmodel();
        }
        return this._instance;
    }

    public title:string = "";
    public itemDataList:itemData[] = [];
    
    initData()
    {
        this.title = "测试";
        this.itemDataList =[
            {name:"测试名字1", value1:120, value2: 133, value3: 2421},
            {name:"测试名字2", value1:24, value2: 334, value3: 233},
            {name:"测试名字3", value1:1520, value2: 21, value3: 44221},
            {name:"测试名字4", value1:644, value2: 32, value3: 233},
            {name:"测试名字5", value1:532, value2: 553, value3: 3224},
            {name:"测试名字6", value1:434, value2: 324, value3: 213},
            {name:"测试名字7", value1:232, value2: 455, value3: 221},
            {name:"测试名字8", value1:44, value2: 33, value3: 422},
            {name:"测试名字9", value1:56, value2: 221, value3: 4212},
            {name:"测试名字10", value1:233, value2: 2324, value3: 4212},
        ]
        this.sort_data();
    }

    sort_data()
    {
        this.itemDataList.sort((a,b) => {
            if(a.value1 < b.value1) 
                return 1;
            else
                return -1;
        });
    }

    add_Item(data:itemData)
    {
        this.itemDataList.push(data);
        this.sort_data();
    }

}




